package com.hjq.www.View;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Create with IntelliJ IDEA
 *
 * @author: hjq
 * @Date:
 * @Description:
 */
public class TicketView extends JFrame {
    private final Container container = getContentPane();
    private final JButton bookButton = new JButton("我要购票");
    private final JButton cancelButton = new JButton("我要退票");
    private final JButton backButton = new JButton("返回");
    public TicketView() {
        setTitle("票务窗口");
        //设置窗口大小
        setBounds(620, 160, 300, 500);
        //添加一块桌布
        container.setLayout(new BorderLayout());
        //初始化窗口
        init();
        //设计窗口可见
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public void init() {
        JPanel root = new JPanel();
        root.setLayout(null);
        bookButton.setBounds(3, 5, 280, 135);
        cancelButton.setBounds(3, 165, 280, 135);
        backButton.setBounds(3,321,280,135);
        bookButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        cancelButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        backButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new MainView().init();
                dispose();
            }
        });
        root.add(bookButton);
        root.add(cancelButton);
        root.add(backButton);
        container.add(root);
    }

    public static void main(String[] args) {
        new TicketView();
    }
}
